#--------------------------------------------
# Compilation Flags
#--------------------------------------------

if ( CMAKE_BUILD_TYPE MATCHES "Release" )
   message ( STATUS "Compiling in Release mode" )
   add_definitions ( -O2 -march=native )
elseif( CMAKE_COMPILER_IS_GNUCXX )
   # Add additional GCC options.
   add_definitions (
     -ggdb3 -fno-strict-aliasing -Wall -Wextra
     -Wchar-subscripts -Wundef -Wcast-align -Wwrite-strings
     -Wsign-compare -Wunused -Wuninitialized -Winit-self
     -Wpointer-arith -Wredundant-decls -Wformat-nonliteral
     -Wmissing-format-attribute -Wformat-security
   )
elseif ( CMAKE_CXX_COMPILER MATCHES "clang" )
   add_definitions ( -Wall -Wextra )
endif ( )

#--------------------------------------------
# Required libraries
#--------------------------------------------

## Boost
find_package ( Boost COMPONENTS program_options date_time system filesystem unit_test_framework REQUIRED )
include_directories ( ${Boost_INCLUDE_DIRS} )
link_directories ( ${Boost_LIBRARY_DIRS} )

## OpenCV
find_package ( OpenCV REQUIRED )

#--------------------------------------------
# Optional libraries
#--------------------------------------------

## OpenMP
option ( ENABLE_OPENMP "multi-threading with OpenMP" ON )

if ( ENABLE_OPENMP )
   message ( STATUS "OpenMP support enabled" )
   find_package ( OpenMP )
   if ( OPENMP_FOUND )
      message ( STATUS "OpenMP found" )
      set ( CMAKE_C_FLAGS           "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}" )
      set ( CMAKE_CXX_FLAGS         "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}" )
      set ( CMAKE_EXE_LINKER_FLAGS  "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}" )
   else ( )
      message ( STATUS "OpenMP support disabled (can't find library)" )
   endif ( )
else ( )
   message ( STATUS "OpenMP support disabled" )
endif()

